<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<HTML XMLNS="http://www.w3.org/1999/xhtml">
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1" />
<TITLE>AdminPanel</TITLE>
<LINK HREF="file:///c|/inetpub/wwwroot/Bkdraper/AfterHours/UniversalStyleSheet.css" REL="stylesheet" TYPE="text/css" />


<SCRIPT type="text/javascript">
function BtnExcel_click()
    {
	url="ExcelReport.asp";
	params="height=725, width=1000,status=no,resizable=yes,scrollbars=yes";
	window.open(url,"ExcelReport",params);
    }

function OpenEditFileName()
    {
	fn=document.ExcelForm.FileNameFormat.value;
	url="EditFileNameFormat.asp?filename=" + fn;
	params="width=500,height=150,screenX=200,screenY=200";
	window.open(url,"EditFileName",params);
	}


function SetMessageToUsers()
    {
	msg=document.getElementById("MessageToUsers").value;
	
	message=escape(msg)
	window.location.href="admin.asp?action=messagetousers&MessageToUsers=" + message;
	}

function ReleaseUser(user)
    {
	window.location.href="admin.asp?action=freeusername&FreeUserName=" + user;
	}


function SaveFileName_click()
    {
	fn=document.getElementById("FileNameFormat").value;
	filename=fn.replace(" ","_");
	window.location.href="admin.asp?action=saveexcelfilename&filename=" + filename;
	}

</SCRIPT>


<%
select case request.QueryString("action")
	case "freeusername"
		userlist=split(application("users"),"|")
		Uidlist=split(application("Uids"),"|")
		x=0
		do until x>ubound(userlist)
			if userlist(x)<>request.QueryString("FreeUserName") then
				z=z+1
				if z=1 then
					temp=userlist(x)
					temp2=Uidlist(x)
				else
					temp=temp & "|" & userlist(x)
					temp2=temp2 & "|" & Uidlist(x)
				end if
			end if
			x=x+1
		loop
		application("users")=temp
		application("Uids")=temp2
		%>
		<SCRIPT type="text/javascript">
			window.location.href="admin.asp";
		</SCRIPT>
		<%
		
	case "messagetousers"
		set fs=server.CreateObject("scripting.filesystemobject")
		filepath=server.MapPath("access/backend/Message.txt")
		set tf=fs.opentextfile(filepath,2,true)
		tf.writeline(request.QueryString("MessageToUsers"))
		tf.close
		set tf=nothing
		set fs=nothing
		%>
		<SCRIPT type="text/javascript">
			alert("** Message Set. Users will see it when their application refreshes\nMost likely within the next minute. **");
			window.location.href="admin.asp";
		</SCRIPT>
		<%
	
	case "saveexcelfilename"
		set db=server.CreateObject("adodb.connection")
		set rs=server.CreateObject("adodb.recordset")
		filepath=server.MapPath("/afterhours/access/backend/admin.mdb")
		db.open ("provider=microsoft.jet.oledb.4.0;data source=" & filepath)
		sql="excel"
		rs.open sql,db,1,2
		rs.movefirst
		filename=request.QueryString("filename")
		if filename<>"" then
			filename=replace(filename,"_"," ")
		end if
		rs("filenameformat")=filename
		rs.update
		rs.close
		db.close
		%>
		<SCRIPT type="text/javascript">
			alert("FileName Format Saved");
			window.location.href="admin.asp";
		</SCRIPT>
<%
	case ""
		set db=server.CreateObject("adodb.connection")
		set rs=server.CreateObject("adodb.recordset")
		filepath=server.MapPath("/afterhours/access/backend/admin.mdb")
		db.open ("provider=microsoft.jet.oledb.4.0;data source=" & filepath)
		sql="excel"
		rs.open sql,db,1,2
		rs.movefirst
		filenameformat=cstr(rs("filenameformat"))
		rs.close
		db.close

end select
%>

<LINK HREF="UniversalStyleSheet.css" REL="stylesheet" TYPE="text/css">
</HEAD>

<BODY>
<!-- <SCRIPT LANGUAGE="JavaScript">cp.writeDiv()</SCRIPT> -->

<TABLE WIDTH="740" BORDER="0" CELLSPACING="0" CELLPADDING="0">
  <TR>
    <TD WIDTH="20" HEIGHT="20" BACKGROUND="Images/TableUpperLeft.png"></TD>
    <TD WIDTH="700" HEIGHT="20" BACKGROUND="Images/TableUpperMiddle.png"></TD>
    <TD WIDTH="20" HEIGHT="20" BACKGROUND="Images/TableUpperRight.png"></TD>
  </TR>
  <TR>
    <TD WIDTH="20" HEIGHT="20" BACKGROUND="Images/TableMiddleLeft.png"></TD>
    <TD BGCOLOR="#FFFFFF">
	<TABLE WIDTH="92%" BORDER="0" CELLPADDING="0" CELLSPACING="1" BGCOLOR="#009900">
  <TR>
    <TD WIDTH="22%" BGCOLOR="#FFFFFF" CLASS="TableTitles">Users Online </TD>
    <TD WIDTH="78%" BGCOLOR="#FFFFFF" CLASS="TableTitles"><TABLE WIDTH="140" BORDER="1" CELLPADDING="0" CELLSPACING="0" BORDERCOLOR="#009900" ID="Userstable">
      <% 'fill table of users 
	userlist=split(application("users"),"|")
	IDlist=split(application("Uids"),"|")
	x=0
	do until x>ubound(userlist)
	%>
      <TR>
        <TD WIDTH="73" ALIGN="center"><%=userlist(x) %></TD>
        <TD WIDTH="30"><%= IDlist(x) %></TD>
        <TD WIDTH="31"><INPUT NAME="button" TYPE="button" CLASS="buttons" TITLE="Clicking 'Release' Will Log Out Of This Application The User That Is To The Left Of This Button, Causing That Users Screen To Revert Back To The Log-In Screen When That Users Application Refreshes (SomeTime Within This Minute)" onClick="ReleaseUser('<%= userlist(x) %>')" VALUE="Release"/></TD>
      </TR>
      <%
  	x=x+1
	loop
  %>
    </TABLE></TD>
  </TR>
  <TR>
    <TD BGCOLOR="#FFFFFF" CLASS="TableTitles">Message To Users<BR>
      (100 characters Max) </TD>
    <TD BGCOLOR="#FFFFFF" CLASS="TableTitles"><FORM ACTION="" METHOD="post" NAME="UserMsgForm" ID="UserMsgForm">
	<%
	set fs=server.CreateObject("scripting.filesystemobject")
	filepath=server.MapPath("access/backend/message.txt")
	set mf=fs.opentextfile(filepath)
	msg=mf.readline
	mf.close
	set mf=nothing
	set fs=nothing
	%>
      <INPUT NAME="MessageToUsers" TYPE="text" ID="MessageToUsers" SIZE="60" MAXLENGTH="100" STYLE="background-color:#FFFF99" VALUE="<%= msg %>"/>
      <INPUT NAME="BtnSet" TYPE="button" CLASS="buttons" ID="BtnSet" TITLE="Clicking 'Set' Will Set The Message Currently Typed Into The Text Box To The Left As The Message That Is Displayed To All Users Of This Application Viewed In The Center Of The Application Header Bar" onClick="SetMessageToUsers()" VALUE="Set" />

      <INPUT NAME="BtnItalic" TYPE="button" CLASS="buttons" ID="BtnItalic" VALUE="I" onClick="javascript:InsertTag(this.form.MessageToUsers,'<i>','</i>')">
    </FORM>
	</TD>
  </TR>
  <TR>
    <TD BGCOLOR="#FFFFFF" CLASS="TableTitles">Excel Report<BR>
      (Opens in separate window) </TD>
    <TD BGCOLOR="#FFFFFF" CLASS="TableTitles">
	<FORM ACTION="" onSubmit="" METHOD="post" NAME="ExcelForm" ID="ExcelForm">
      <INPUT NAME="BtnExcel" TYPE="button" CLASS="buttons" ID="BtnExcel" TITLE="Click 'Report Maker' To Open The Report Making Tool Used To Create Excel Reports Out Of Ticket Data For A Specified TimeFrame" onClick="BtnExcel_click()" VALUE="ReportMaker">

        <BR>
        <BR>
        FileName Format 
        <INPUT NAME="FileNameFormat" TYPE="text" ID="FileNameFormat" SIZE="50" VALUE="<%= filenameformat %>" STYLE="background-color:#FFFF99">
        <INPUT NAME="BtnSaveFileName" TYPE="submit" CLASS="buttons" ID="BtnSaveFileName" TITLE="Clicking 'Save' Will Save What Is Currently Entered Into The TextBox To The Left As the Format In Which Excel Reports' FileNames Will Be Named" onClick="SaveFileName_click()" VALUE="Save">
        <INPUT NAME="BtnEditFileName" TYPE="button" CLASS="buttons" ID="BtnEditFileName" TITLE="Clicking 'Edit' Will Open A Pop-Up Window Allowing You A More Advanced Method Of Creating The Format In Which Excel Reports' FileName Will Appear" onClick="OpenEditFileName()" VALUE="Edit">
    </FORM>
    <BR></TD>
  </TR>
</TABLE>
   </TD>
    <TD WIDTH="20" BACKGROUND="Images/TableMiddleRight.png"></TD>
  </TR>
  <TR>
    <TD WIDTH="20" HEIGHT="20" BACKGROUND="Images/TableLowerLeft.png"></TD>
    <TD WIDTH="700" HEIGHT="20" BACKGROUND="Images/TableLowerMiddle.png"></TD>
    <TD WIDTH="20" BACKGROUND="Images/TableLowerRight.png"></TD>
  </TR>
</TABLE>

</BODY>
</HTML>
